Add native Python SDK configuration (python version, uv, base image)#1
Merged
Conversation
Add a Go helper that reads and edits a module's pyproject.toml, preserving unrelated keys. Covers python version (requires-python), use-uv ([tool.dagger]), and base-image ([tool.dagger]). Signed-off-by: Yves Brissaud <yves@dagger.io>
Add the command-line front end: get-* print values, set-*/unset-* edit the file in place. Signed-off-by: Yves Brissaud <yves@dagger.io>
Add ModConfig with typed readers (pythonVersion/useUv/baseImage) and mutators (setPythonVersion/setUseUv/setBaseImage/unsetBaseImage), backed by the pyproject helper. Wire it onto Mod as mod.config. Signed-off-by: Yves Brissaud <yves@dagger.io>
init gains --python-version, --use-uv, and --base-image. Non-default flags are applied to the rendered template's pyproject.toml via the pyproject helper before writing; defaults leave the template untouched. Signed-off-by: Yves Brissaud <yves@dagger.io>
Add config/app and config/configured fixtures plus configCheck and initConfigCheck verifying readers, single-file edits, unset round-trip, and init flag output. Signed-off-by: Yves Brissaud <yves@dagger.io>
Document init config flags and the mod.config read/write commands. Signed-off-by: Yves Brissaud <yves@dagger.io>
TomChv
approved these changes
May 27, 2026
Member
|
Early approval, is that expected though if the module does not load? |
Contributor
|
@TomChv if you're referring to the ci checks, yeah I think its expected that it only loads with the |
get-use-uv now prints nothing when [tool.dagger].use-uv is absent so callers can distinguish an unset value from an explicit choice instead of guessing the uv default. getUseUv returns (value, ok) accordingly. Drop the unset-base-image command: the config surface no longer supports clearing a value back to unset. Signed-off-by: Yves Brissaud <yves@dagger.io>
Replace the seven config functions (pythonVersion/useUv/baseImage readers and setPythonVersion/setUseUv/setBaseImage/unsetBaseImage mutators) with two: config.get and config.set. config.get returns a ModConfigValues object whose fields are null when the corresponding setting is not written to pyproject.toml, so unset values are reported rather than guessed. config.set takes optional pythonVersion, useUv and baseImage flags and applies them in one call; omitting a flag leaves that setting untouched. Signed-off-by: Yves Brissaud <yves@dagger.io>
Update configCheck for the new two-function surface: assert config.get reports unset values as null, assert a multi-value config.set writes all three settings, and assert a partial set leaves omitted settings untouched. Signed-off-by: Yves Brissaud <yves@dagger.io>
Replace the per-field config read/write commands in the README with the new config get and config set usage. Signed-off-by: Yves Brissaud <yves@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
The pinned polyfill (d6ab640) stamped DAGGER_TRACE_URL=cloud.traceURL
into its workspace-snapshot helper container. Evaluating cloud.traceURL
hits the engine's Cloud.traceURL resolver, which hard-errors with
"no cloud organization configured" when no Dagger Cloud org is set.
This made init (and any changeset-producing call) fail unless the user
had run `dagger login`.
Upstream sdk-sdk e0304c6 ("Remove Dagger Cloud trace dependency from
test rails") dropped that env var. Bump the pin to main (09da957) so
local scaffolding works without a Dagger Cloud org.
Signed-off-by: Yves Brissaud <yves@dagger.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make Python module customization first-class in the
python-sdkmodule, instead of requiring users to hand-editpyproject.toml. Three settings are exposed: Python version, uv vs pip, and base image — both at creation time (viainitflags) and afterward (viamod ... configcommands). All settings persist to the module'spyproject.toml.Configure at creation
dagger call python-sdk init --name my-module \ --python-version 3.13 \ --use-uv=false \ --base-image python:3.13-slimAll flags are optional. Defaults leave the template untouched (template Python version, uv enabled, no base image override).
Configure an existing module
mod ... configexposes two functions:getandset.Read the current configuration. Settings not explicitly written to
pyproject.tomlare reported asnullrather than guessed:Select a single value:
Change one or more values at once (returns a
Changeset, prompting before writing). Each flag is optional; omitting one leaves that setting untouched:dagger call python-sdk mod --path my-module config set \ --python-version 3.13 \ --use-uv=false \ --base-image python:3.13-slimWhere it's stored
pyproject.toml[project].requires-python = ">=X.Y"[tool.dagger].use-uv(written only whenfalse; absent ⇒ uv)[tool.dagger].base-image(absent ⇒ SDK default)How it works
A small TOML-aware Go helper (
helpers/pyproject) reads/editspyproject.toml, preserving unrelated keys and pruning empty tables. Both theinitflags and themod.configcommand surface drive that single helper, so there is one source of truth for reading and writing config.Reads never guess: an absent
use-uvis reported as unset rather than defaulting totrue, soconfig getdistinguishes "not configured" from an explicit choice.Testing
helpers/pyproject).configCheckandinitConfigCheckcoverconfig get(including unset-reported-as-null),config set(multi-value and partial/leave-untouched), single-file-scope edits, andinitflag output.